package com.ymatou.iapi.userregister.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 用户注册接口Call FreeMaker Template自动生成代码
 */
public class UserRegisterInfoRequestDtoCall extends YmatouBaseCall {
	private static String opurl = "json/reply/UserRegisterInfoRequestDto";

	public UserRegisterInfoRequestDtoCall() {
		super(EnvSetup.getSystemUrl("userregister_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取ResponseCode
	 * 
	 * @return
	 */
	public int getResponseCode() {
		int ResponseCode = 0;
		try {
			ResponseCode = new JSONObject(getReturnData()).getInt("ResponseCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResponseCode;
	}

	/**
	 * 获取Result
	 * 
	 * @return
	 */
	public JSONObject getResult() {
		JSONObject Result = null;
		try {
			Result = new JSONObject(getReturnData()).getJSONObject("Result");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result;
	}

	/**
	 * 获取userid
	 * 
	 * @return
	 */
	public int getUserid() {
		int Userid = 0;
		try {
			Userid = getResult().getInt("UserId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Userid;
	}

	/**
	 * 获取userid
	 * 
	 * @return
	 */
	public String getAccessToken() {
		String Userid = null;
		try {
			Userid = getResult().getString("Token");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Userid;
	}
	
	
	/**
	 * 获取userid
	 * 
	 * @return
	 */
	public String getVerifyCode() {
		String code = null;
		try {
			code = getResult().getString("VerifyCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return code;
	}

	
	/**
	 * 获取Result
	 * 
	 * @return
	 */
	public String getLastErrorMessage() {
		String Result = null;
		try {
			Result = new JSONObject(getReturnData()).getString("LastErrorMessage");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result;
	}
}